/**
 * 手动备份测试
 */
package com.axt.dbaudit.unitTest;

import java.util.List;

import com.axt.dbaudit.bean.ManualBackUpDBBean;
import com.axt.dbaudit.model.ManualBackUpDB;
import com.opensymphony.xwork2.util.finder.Test;

public class SoaManualBackupTest {
	ManualBackUpDBBean manualBackUpDBBean;

	void test() {
		manualBackUpDBBean = new ManualBackUpDBBean();

		testGetBackInfo();
		testBeginBack();
		testGetProgress();
		testDeleteFiles();
	}

	void testGetBackInfo() {
		List<ManualBackUpDB> oList = manualBackUpDBBean.queryBackUpInfos();
		if (oList != null) {
			System.out.println("获得列表成功");
		}

	}

	void testBeginBack() {
		boolean bRet = false;
		bRet = new ManualBackUpDBBean().BeginBackUpDB("/bjaxt/media0",
				"2012-5-11", "bjaxt");
		if (bRet) {
			System.out.println("开始备份数据");
		}
	}

	void testGetProgress() {
		String sProgressMsg = "备份已经完成";
		List<ManualBackUpDB> sMsg = null;
		do {
			sMsg = manualBackUpDBBean.queryBackUpProgress();
			if (sMsg != null && sMsg.size() > 0) {
				System.out.println(sMsg.get(0).getProgressMsg() + ":"
						+ sMsg.get(0).getProgressPos());
			} else {
				System.out.println("获取备份进度失败");
				break;
			}

		} while (sMsg.get(0).getProgressMsg() != sProgressMsg);

		System.out.println(sProgressMsg);
	}

	void testDeleteFiles() {
		boolean bRet = false;
		bRet = manualBackUpDBBean.DeleteFiles("2012-5-11");
		if (bRet) {
			System.out.println("删除成功");
		}
	}

	public static void main(String[] args) throws Exception {
		new SoaManualBackupTest().test();
	}

}
